#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

const int maxcol = 60;
const int maxn = 105;
std::string filenames[maxn];

void print(const std::string &, int, char);

int main() {
  int n, i, m;
  
  while (std::cin >> n) {
    m = 0;
    for (i = 0; i < n; i++) {
      std::cin >> filenames[i];
      m = std::max(m, (int)filenames[i].length());
    }

    std::sort(filenames, filenames + n);
    /*
     * cols:
     *   先去掉最後一個 filename
     *   除以(最長 filename 長度 + 2)
     *   再加回去掉的 1
     * rows:
     *   總檔案數量 n / 每列數量
     *   有小數的話進位 (+1)
     */
    print("", maxcol, '-');
    std::putchar('\n');
    int cols = (maxcol - m) / (m + 2) + 1, rows = ceil(n / (double)cols), r, c;
    for (r = 0; r < rows; r++) {
      for (c = 0; c < cols; c++) {
        int idx = c * rows + r;
        if (idx < n) {
          print(filenames[idx], c == (cols - 1) ? m : (m + 2), ' ');
        }
      }
      std::putchar('\n');
    }
  }

  return 0;
}

void print(const std::string &s, int mlen, char padding) {
  std::cout << s;
  int i, padlen = mlen - s.length();
  for (i = 0; i < padlen; i++) {
    std::putchar(padding);
  }
}
